package cz.cvut.fit.crhonjar.mi.paa.dunedin.solver;

import java.util.Comparator;
import java.util.PriorityQueue;

import cz.cvut.fit.crhonjar.mi.paa.dunedin.Bucket;
import cz.cvut.fit.crhonjar.mi.paa.dunedin.State;

public class DistanceFromFinalSolver extends Solver {

	@Override
	public void initializeQue() {
		final Comparator<State> c = new Comparator<State>() {

			@Override
			public int compare(final State s1, final State s2) {
				int distance1 = 0;
				int distance2 = 0;
				for (final Bucket b : s1.getBuckets()) {
					distance1 += Math.abs(b.getFinalVolume() - b.getActual());
				}

				for (final Bucket b : s2.getBuckets()) {
					distance2 += Math.abs(b.getFinalVolume() - b.getActual());
				}
				return distance1 - distance2;
			}

		};
		this.que = new PriorityQueue<State>(1024, c);
	}

}
